package com.mrzhou.monitor.service;

import org.springframework.stereotype.Service;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.HardwareAbstractionLayer;

@Service
public class MonitorServiceImpl {

    public static void main(String[] args) {
        SystemInfo systemInfo = new SystemInfo();
        HardwareAbstractionLayer layer = systemInfo.getHardware();
        CentralProcessor processor = layer.getProcessor();
        long[] cpuLoadTicks = processor.getSystemCpuLoadTicks();
        // 系统层次的CPU使用率
        long system = cpuLoadTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
        // 用户层面的CPU使用率
        long user = cpuLoadTicks[CentralProcessor.TickType.USER.getIndex()];

        long[] maxFreq = processor.getCurrentFreq();

        System.out.println(processor.getMaxFreq());
    }


}
